﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] DigitCode = {"-!","**","!!!","&&","&-","!-","*!!!","&*!","!!**!-"};

            Console.WriteLine("Input 9Gad Numbers:");
            string Input9Gad = Console.ReadLine();
              //This is only for one Digit 
            for (byte i=0; i<DigitCode.Length ;i++)
            {  
                
                if (Input9Gad == DigitCode[i])
                {
                    Console.WriteLine("It is easy to me:{0} ",  i);
                     return;
                }
                i++;
             }

               //For more complex 
             //StringBuilder Decode = StringBuilder();
               int number=0;
               int possition;
               int[] digit=new int[20];
               int k=0;
               int len=0;

               do
               {
                   for (byte i = 0; i < DigitCode.Length; i++)
                   {

                       possition = (Input9Gad.IndexOf(DigitCode[i], len));
                       if (possition != -1)   //There is a digit ;
                       {
                           if (possition !=len) continue;
                           number = DigitCode[i].Length;
                           len += number;
                           digit[k++] = i;

                       }

                   }
               } while (len < Input9Gad.Length-2);

              double result;
               k--;
               result = digit[k--];
               int pow = 1;
               do
               {
                   Math.Pow(9, pow);
                   result += digit[k--] * Math.Pow(9,pow);
                   pow++;
               } while (k >= 0);
              

            Console.WriteLine("This is more comples :{0}" , result);








            
             Console.Beep();



        }
    }
}
